import { Injectable } from '@nestjs/common';
import { CreateWireDto } from './dto/create-wire.dto';
import { UpdateWireDto } from './dto/update-wire.dto';
import { PrismaService } from 'src/prisma/prisma.service';

@Injectable()
export class WireService {
  constructor(private prisma: PrismaService) {}
  async create(createWireDto: CreateWireDto) {
    return await this.prisma.wire.create({ data: createWireDto });
  }

  async createMany(data: CreateWireDto[]) {
    return await this.prisma.wire.createMany({ data });
  }

  async findAll(args: Record<string, any>) {
    const { projId } = args;
    return await this.prisma.wire.findMany({ where: { projId: +projId } });
  }

  findOne(id: number) {
    return `This action returns a #${id} wire`;
  }

  async update(id: number, updateWireDto: UpdateWireDto) {
    return await this.prisma.wire.update({
      where: { id },
      data: updateWireDto,
    });
  }

  async remove(id: number) {
    return await this.prisma.wire.delete({ where: { id } });
  }
}
